from math import *
from itertools import *
 
def Deform (memb):
    if(memb.count(',') > 0) :
        temp = map(int,memb.split(','))
        temp.sort()
        return xrange( temp[0],temp[1]+1)
    else:
        return [int(memb)]
 
expr = raw_input()
params = "Param=3 Fun=-21,45 Result=5,15"
params = map(lambda x: x.split('='),params.split())
values = map(lambda x: Deform(x[1]), params)
Keys = map(lambda x: x[0],params)

print params
print values
print Keys

Max = ''    
for i in product(*values) :
    Dic = {j[0]:j[1]  for j in zip(Keys,i)}
    print Dic
    try:
        temp = eval(expr,globals(),Dic)
    except:
        pass
    else:
        if Max =='':
            Max = temp
        else:
            Max = max(Max,temp)
 
print Max

